package com.hfjyz.system.depart.service;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hfjyz.base.constant.BaseConstant;
import com.hfjyz.base.entity.DepartEntity;
import com.hfjyz.base.exception.BaseException;
import com.hfjyz.system.depart.bean.DepartBean;
import com.hfjyz.system.depart.dao.DepartDao;

public class DepartService {
    private static final Log SYS_LOG = LogFactory.getLog(BaseConstant.SYS_LOG);
    private DepartDao dao = null;

    public DepartDao getDao() {
        return dao;
    }

    public void setDao(DepartDao dao) {
        this.dao = dao;
    }

    public List<DepartBean> listDepart() throws BaseException {
        try {
            List<DepartEntity> entityList = dao.listDepart();
            List<DepartBean> deptList = new ArrayList<DepartBean>();
            for (DepartEntity entity : entityList) {
                deptList.add(new DepartBean(entity));
            }
            SYS_LOG.error("获取部门信息成功！");
            return deptList;
        } catch (Exception e) {
            SYS_LOG.error("获取部门信息失败！", e);
            throw new BaseException("获取部门信息失败！", e);
        }
    }
}
